package com.lixingqu.mvpdemo.ui.news;

import com.lixingqu.mvpdemo.entity.HttpResultEntity;
import com.lixingqu.mvpdemo.entity.NewsEntity;
import com.lixingqu.mvpdemo.net.NetWorks;

import java.util.List;

import rx.Observable;

/**
 * Created by lixingqu on 2016/12/2.
 */

public class NewsModelImpl implements NewsContract.Model {
    private String TIYU = "tiyu";
    private int num = 10;
    private int index = 1;
    @Override
    public Observable<HttpResultEntity<List<NewsEntity>>> getNews() {
        return NetWorks.getInstance().getHttpService().getContent(TIYU,TIYU,String.valueOf(num),String.valueOf(index));
    }

    @Override
    public Observable<HttpResultEntity<List<NewsEntity>>> refresh() {
        index = 1;
        return NetWorks.getInstance().getHttpService().getContent(TIYU,TIYU,String.valueOf(num),String.valueOf(index));
    }

    @Override
    public Observable<HttpResultEntity<List<NewsEntity>>> loadMore() {
        index = index +1;
        return NetWorks.getInstance().getHttpService().getContent(TIYU,TIYU,String.valueOf(num),String.valueOf(index));
    }
}
